{% extends 'admin/layout.html.twig' %}

{% set script_controller = 'coupon/query' %}

{% set menu = 'admin_operation_coupon_query' %}

{% block main %}
  {{ web_macro.flash_messages() }}

  <form id="coupon-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
	<div class="form-group">
	  <select class="form-control" name="status">
	    {{ select_options(dict('couponStatus'), app.request.query.get('status'), 'coupon.query.by_status'|trans) }}
	  </select>
	</div>
	<div class="form-group">
	  <select class="form-control" name="type">
	    {{ select_options(dict('couponType'), app.request.query.get('type'), 'coupon.query.by_type'|trans) }}
	  </select>
	</div>
	<div class="form-group">
	  <input type="text" id="useStartDateTime" value="{{app.request.query.get('useStartDateTime')}}" name="useStartDateTime" class="form-control" placeholder="{{ 'coupon.query.by_use_start_date'|trans }}" styuseStartDateTimele="width:150px;">
	  </div>
	<div class="form-group">
	  <input type="text" id="useEndDateTime" value="{{app.request.query.get('useEndDateTime')}}" name="useEndDateTime" class="form-control" placeholder="{{ 'coupon.query.by_use_end_date'|trans }}" style="width:150px;">
	  </div>
	<div class="form-group">
	  <input class="form-control" type="text" placeholder="{{ 'coupon.code'|trans }}" name="code" value="{{ app.request.get('code') }}">
	</div>
	<button class="btn btn-primary">{{ 'form.btn.search'|trans }}</button>
</form>

<table class="table table-striped" id="coupon-list">
	<thead>
	    <tr>
	      <th style="width:10%">{{ 'coupon.id'|trans }}</th>
	      <th style="width:10%">{{ 'coupon.code'|trans }}</th>
	      <th style="width:5%">{{ 'coupon.target_type'|trans }}</th>
	      <th style="width:10%">{{ 'coupon.status'|trans }}</th>
	      <th style="width:7%">{{ 'coupon.user'|trans }}</th>
	      <th>{{ 'coupon.order'|trans }}</th>
	      <th>{{ 'coupon.content'|trans }}</th>
	      <th style="width:5%">{{ 'coupon.origin_price'|trans }}</th>
	      <th style="width:5%">{{ 'coupon.pay_amount'|trans }}</th>
	      <th style="width:10%">{{ 'coupon.batch.name'|trans }}</th>
	      <th>{{ 'coupon.receive_time'|trans }}</th>
	      <th>{{ 'coupon.used_time'|trans }}</th>
	    </tr>
	</thead>
	<tbody>
      {% for coupon in coupons %}
      	{% set order = orders[coupon.orderId]|default(null) %}
      	{% set batch = batchs[coupon.batchId]|default(null) %}
      	{% set user = users[coupon.userId]|default(null) %}
        {% include 'admin/coupon/coupon-tr.html.twig' %}
      {% else %}
        <tr class="empty"><td colspan="20">{{ 'coupon.no_coupon_tip'|trans }}</td></tr>
      {% endfor %}
	</tbody>
</table>
  {{ web_macro.paginator(paginator) }}

{% endblock %}
